package com.aqumon.www.service;

import com.aqumon.www.entity.dto.JenkinsBuildInfoDto;
import com.aqumon.www.entity.dto.JenkinsJobBuildDto;
import com.aqumon.www.entity.persistent.JenkinsBuild;
import com.aqumon.www.entity.persistent.JenkinsConfig;
import com.aqumon.www.entity.request.jenkins.JobBasicReq;
import com.aqumon.www.entity.request.jenkins.JobBuildReq;
import com.aqumon.www.entity.response.jenkins.BuildRecordResp;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;

/**
 * <p>
 * job 部分构建表 服务类
 * </p>
 *
 * @author aqumon
 * @since 2022-05-19
 */
public interface JenkinsBuildService extends IService<JenkinsBuild> {

    /**
     * 获取job特殊build信息，如上次构建，上次成功构建，上次失败构建等
     * @return
     */
    List<BuildRecordResp> getBuildList(Long scriptId);

    /**
     * 获取job参数，无参数返回null
     * @return List<BuildResp>
     */
    List<JenkinsJobBuildDto> getJobParams(String jenkinsName, String jobFullName);

    /**
     * 获取最近一次构建状态
     */
    JenkinsBuildInfoDto getLastBuildInfo(JenkinsConfig jenkinsConfig, String jobFullName);

    /**
     * 获取指定buildNumber构建基本信息
     */
    JenkinsBuildInfoDto getBuildInfo(String jenkinsName, String jobFullName, Long buildNumber);

    /**
     * 获取指定buildNumber构建日志
     */
    String getBuildLog(String jenkinsName, String jobFullName, Long buildNumber);

    /**
     * 停止最后构建的 Job Build
     */
    String stopLastJobBuild(JobBasicReq jobBasicReq);

    /**
     * 构建job
     * @return List<BuildResp>
     */
    boolean buildJob(JobBuildReq jobBuildReq);

    /**
     * 获取构建历史
     * @return List<BuildResp>
     */
    boolean disableJob(JobBasicReq jobBasicReq);

    /**
     * 获取构建历史
     * @return List<BuildResp>
     */
    boolean enableJob(JobBasicReq jobBasicReq);

}
